package myStudent

import org.springframework.cloud.contract.spec.Contract
import org.springframework.cloud.contract.spec.internal.MatchingTypeValue

import java.lang.reflect.Type

Contract.make {
    request {
        method 'GET'
        url value(consumer(regex('/api/v2/myStudents/programs/\\d+/students/assignments')),
                producer('/api/v2/myStudents/programs/1/students/assignments'))
        headers {
            contentType(applicationJsonUtf8())
            header("id", 1)
        }
    }
    response {
        status 200
        body("""
        [{
          "task":{},
          "assignment":{},
           "topic":{},
           "situation":{}
        }]
        """)
        bodyMatchers {
            jsonPath('$.[*]', byType())
            jsonPath('$.[*].task.id', byRegex(number()))
            jsonPath('$.[*].assignment.id', byRegex(number()))
            jsonPath('$.[*].topic.id', byRegex(number()))
            jsonPath('$.[*].situation', byType())
        }
        headers {
            contentType(applicationJsonUtf8())
        }
    }
}